#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Bootstrap Viewlet Module

Mikan Python Web Framework
"""

__author__ = "K.Sonohara"
__status__ = "develop"
__version__ = "0.0.0_45"
__date__    = "2014/05/04"
__license__ = 'LGPL'

# ------------------------------------------------------------
## Import Section
# ------------------------------------------------------------
# Python
import platform
import socket
import traceback
import calendar
from random import Random
from datetime import datetime

# ESiPC
from esipc.calendar import get_holiday
from esipc import ESiPCProperty

# Mikan
from mikan.core import MIKAN
from mikan.viewlet import MikanImgViewlet, MikanAViewlet, MikanDivViewlet, MikanPViewlet,\
	MikanSpanViewlet, MikanUlViewlet, MikanDlViewlet, MikanLiViewlet, MikanOlViewlet, MikanButtonViewlet,\
	MikanTextViewlet, MikanH4Viewlet, MikanH5Viewlet, MikanTableViewlet, MikanTrViewlet, MikanThViewlet,\
	MikanTdViewlet, MikanTheadViewlet, MikanTbodyViewlet, MikanBrViewlet, MikanInputViewlet, MikanCDataViewlet,\
	MikanCodeViewlet, MikanPreViewlet, MikanFormViewlet, MikanDtViewlet, MikanDdViewlet, MikanHrViewlet,\
	MikanLabelViewlet, MikanCheckboxInputViewlet, MikanSelectViewlet
from mikan.viewlet.jqueryviewlet import MikanBannerSilderItem

# ------------------------------------------------------------
## Variable Section
# ------------------------------------------------------------

# ------------------------------------------------------------
## Mikan Contant
# ------------------------------------------------------------
class MIKAN_BOOTSTRAP(MIKAN):
	DEFAULT = "default"
	PRIMARY = "primary"
	SUCCESS = "success"
	INFO = "info"
	WARNING = "warning"
	DANGER = "danger"

	LINK = "link"

	TEXT_MUTED = "text-muted"
	TEXT_DEFAULT = "text-" + DEFAULT
	TEXT_PRIMARY = "text-" + PRIMARY
	TEXT_SUCCESS = "text-" + SUCCESS
	TEXT_INFO = "text-" + INFO
	TEXT_WARNING = "text-" + WARNING
	TEXT_DANGER ="text-" + DANGER

	TEXT_LEFT = "text-left"
	TEXT_CENTER = "text-center"
	TEXT_RIGHT = "text-right"
	TEXT_JUSTIFY = "text-justify"

	BG_PRIMARY = "bg-" + PRIMARY
	BG_SUCCESS = "bg-" + SUCCESS
	BG_INFO = "bg-" + INFO
	BG_WARNING = "bg-" + WARNING
	BG_DANGER ="bg-" + DANGER

	PULL_LEFT = "pull-left"
	PULL_RIGHT = "pull-right"

	PULL_CARET = "caret"

	BLOCK = "block"

	LG = "lg"
	SM = "sm"
	XS = "xs"

	CENTER_BLOCK = "center-block"

# ------------------------------------------------------------
## Function Section
# ------------------------------------------------------------

def add_link_item2(clazz, viewlet, item):
	li = clazz(viewlet)
	if item.isactive == True:
		li.clazz = "active"
	elif item.isdisabled == True:
		li.clazz = "disabled"
	if item.href != None:
		li = MikanAViewlet(self, href=item.href)
	if item.icon != None:
		li = MikanBootstrapIconViewlet(self, item.icon)
	MikanTextViewlet(li, item.title)

def add_link_item(viewlet, item):
	return add_link_item2(MikanLiViewlet, viewlet, item)

def add_link_items(viewlet, items):
	for item in self.items:
		add_link_item(viewlet, item)

# ------------------------------------------------------------
## Class Section
# ------------------------------------------------------------
class AbstractMikanBootstrapLinkItem(object):

	def __init__(self, title,hint=None,icon_name=None,icon_clazz="glyphicon",clazz=None):
		super(AbstractMikanBootstrapLinkItem, self).__init__()

		self.FIconName = icon_name
		self.FIconClazz = icon_clazz
		self.FTitle = title
		self.FClazz = clazz

	def get_icon_name(self):
		return self.FIconName
	def get_icon_clazz(self):
		return self.FIconClazz
	def get_title(self):
		return self.FTitle
	def get_clazz(self):
		return self.FClazz

	def set_icon_name(self, value):
		self.FIconName = value
	def set_icon_clazz(self, value):
		self.FIconClazz = value
	def set_title(self, value):
		self.FTitle = value
	def set_clazz(self, value):
		self.FClazz = value

	# ----------------------------------------------------
	## Property
	iconname = ESiPCProperty(get_icon_name, set_icon_name, None)
	iconclazz = ESiPCProperty(get_icon_clazz, set_icon_clazz, None)
	title = ESiPCProperty(get_title, set_title, None)
	clazz = ESiPCProperty(get_clazz, set_clazz, None)

class AbstractMikanBootstrapMenuItem(AbstractMikanBootstrapLinkItem):

	def __init__(self, title,hint=None,href="#",target=None,icon_name=None,icon_clazz="glyphicon",active=False,disabled=False,click=None,clazz=None):
		super(AbstractMikanBootstrapMenuItem, self).__init__(title=title,hint=hint,icon_name=icon_name,icon_clazz=icon_clazz,clazz=clazz)

		self.FHref = href
		self.FActive = active
		self.FDisabled = disabled
		self.FTarget = target
		self.FClick = click
		self.FHint = hint

	def get_href(self):
		return self.FHref
	def get_active(self):
		return self.FActive
	def get_disabled(self):
		return self.FDisabled
	def get_target(self):
		return self.FTarget
	def get_click(self):
		return self.FClick
	def get_hint(self):
		return self.FHint

	def set_href(self, value):
		self.FHref = value
	def set_active(self, value):
		self.FActive = value
	def set_disabled(self, value):
		self.FDisabled = value
	def set_target(self, value):
		self.FTarget = value
	def set_click(self, value):
		self.FClick = value
	def set_hint(self, value):
		self.FHint = value

	# ----------------------------------------------------
	## Property
	href = ESiPCProperty(get_href, set_href, None)
	active = ESiPCProperty(get_active, set_active, None)
	disabled = ESiPCProperty(get_disabled, set_disabled, None)
	target = ESiPCProperty(get_target, set_target, None)
	click = ESiPCProperty(get_click, set_click, None)
	hint = ESiPCProperty(get_hint, set_hint, None)


class MikanBootstrapLinkItem(object):

	def set_active(self, value):
		self.FActive = value

	def is_disabled(self):
		return self.FDisabled

	def set_disabled(self, value):
		self.FDisabled = value

	def is_active(self):
		return self.FActive

	def set_href(self, value):
		self.FHref = value

	def get_href(self):
		return self.FHref

	def get_icon(self):
		return self.FIcon

	def set_icon(self, value):
		self.FIcon = value

	def set_title(self, value):
		self.FTitle = value

	def get_title(self):
		return self.FTitle

	def __init__(self, title, href=None, active=False, disabled=False, icon=None):
		super(MikanBootstrapLinkItem, self).__init__()

		self.FTitle = title
		self.FHref = href
		self.FActive = active
		self.FDisabled = disabled
		self.FIcon = icon

	# ----------------------------------------------------
	## Property
	title = ESiPCProperty(get_title, set_title, None)
	href = ESiPCProperty(get_href, set_href, None)
	isactive = ESiPCProperty(is_active, set_active, None)
	isdisabled = ESiPCProperty(is_disabled, set_disabled, None)
	icon = ESiPCProperty(get_icon, set_icon, None)


class AbstractMikanBootstrapDivViewlet(MikanDivViewlet, MIKAN_BOOTSTRAP):

	def __init__(self, parent):
		super(AbstractMikanBootstrapDivViewlet, self).__init__(parent)

class AbstractMikanBootstrapUlViewlet(MikanUlViewlet, MIKAN_BOOTSTRAP):

	def __init__(self, parent):
		super(AbstractMikanBootstrapUlViewlet, self).__init__(parent)

class AbstractMikanBootstrapSpanViewlet(MikanSpanViewlet, MIKAN_BOOTSTRAP):

	def __init__(self, parent):
		super(AbstractMikanBootstrapSpanViewlet, self).__init__(parent)

class AbstractMikanBootstrapButtonViewlet(MIKAN_BOOTSTRAP):

	BUTTON = "btn"

	BUTTON_DEFAULT = MIKAN_BOOTSTRAP.DEFAULT
	BUTTON_PRIMARY = MIKAN_BOOTSTRAP.PRIMARY
	BUTTON_SUCCESS = MIKAN_BOOTSTRAP.SUCCESS
	BUTTON_INFO = MIKAN_BOOTSTRAP.INFO
	BUTTON_WARNING = MIKAN_BOOTSTRAP.WARNING
	BUTTON_DANGER = MIKAN_BOOTSTRAP.DANGER
	BUTTON_LINK = MIKAN_BOOTSTRAP.LINK

	BUTTON_BLOCK = MIKAN_BOOTSTRAP.BLOCK

	BUTTON_LG = MIKAN_BOOTSTRAP.LG
	BUTTON_SM = MIKAN_BOOTSTRAP.SM
	BUTTON_XS = MIKAN_BOOTSTRAP.XS

	def setup_clazz(self, button_type=BUTTON_DEFAULT, size=None, active=False, block=False, tooltip=None):
		self.clazz = "%s %s-%s" % (MikanBootstrapButtonViewlet.BUTTON, MikanBootstrapButtonViewlet.BUTTON, button_type)
		if size:
			self.clazz = "%s %s-%s" % (self.clazz, AbstractMikanBootstrapButtonViewlet.BUTTON, size)
		if active:
			self.clazz = "%s %s" % (self.clazz, AbstractMikanBootstrapButtonViewlet.ACTIVE)
		if block:
			self.clazz = "%s %s-%s" % (self.clazz, AbstractMikanBootstrapButtonViewlet.BUTTON, AbstractMikanBootstrapButtonViewlet.BUTTON_BLOCK)

		if tooltip:
			self.set_attribute_value("data-toggle", "tooltip")
			self.set_attribute_value("data-placement", "top")
			self.set_attribute_value("title", tooltip)


class MikanBootstrapIconViewlet(AbstractMikanBootstrapSpanViewlet):

	GLYPHICON_ASTERISK = "asterisk"
	GLYPHICON_PLUS = "plus"
	GLYPHICON_EURO = "euro"
	GLYPHICON_MINUS = "minus"
	GLYPHICON_CLOUD = "cloud"
	GLYPHICON_ENVELOPE = "envelope"
	GLYPHICON_PENCIL = "pencil"
	GLYPHICON_GLASS = "glass"
	GLYPHICON_MUSIC = "music"
	GLYPHICON_SEARCH = "search"
	GLYPHICON_HEART = "heart"
	GLYPHICON_STAR = "star"
	GLYPHICON_STAR_EMPTY = "star-empty"
	GLYPHICON_USER = "user"
	GLYPHICON_FILM = "film"
	GLYPHICON_TH_LARGE = "th-large"
	GLYPHICON_TH = "th"
	GLYPHICON_TH_LIST = "th-list"
	GLYPHICON_OK = "ok"
	GLYPHICON_REMOVE = "remove"
	GLYPHICON_ZOOM_IN = "zoom-in"
	GLYPHICON_ZOOM_OUT = "zoom-out"
	GLYPHICON_OFF = "off"
	GLYPHICON_SIGNAL = "signal"
	GLYPHICON_COG = "cog"
	GLYPHICON_TRASH = "trash"
	GLYPHICON_HOME = "home"
	GLYPHICON_FILE = "file"
	GLYPHICON_TIME = "time"
	GLYPHICON_ROAD = "road"
	GLYPHICON_DOWNLOAD_ALT = "download-alt"
	GLYPHICON_DOWNLOAD = "download"
	GLYPHICON_UPLOAD = "upload"
	GLYPHICON_INBOX = "inbox"
	GLYPHICON_PLAY_CIRCLE = "play-circle"
	GLYPHICON_REPEAT = "repeat"
	GLYPHICON_REFRESH = "refresh"
	GLYPHICON_LIST_ALT = "list-alt"
	GLYPHICON_LOCK = "lock"
	GLYPHICON_FLAG = "flag"
	GLYPHICON_HEADPHONES = "headphones"
	GLYPHICON_VOLUME_OFF = "volume-off"
	GLYPHICON_VOLUME_DOWN = "volume-down"
	GLYPHICON_VOLUME_UP = "volume-up"
	GLYPHICON_QRCODE = "qrcode"
	GLYPHICON_BARCODE = "barcode"
	GLYPHICON_TAG = "tag"
	GLYPHICON_TAGS = "tags"
	GLYPHICON_BOOK = "book"
	GLYPHICON_BOOKMARK = "bookmark"
	GLYPHICON_PRINT = "print"
	GLYPHICON_CAMERA = "camera"
	GLYPHICON_FONT = "font"
	GLYPHICON_BOLD = "bold"
	GLYPHICON_ITALIC = "italic"
	GLYPHICON_TEXT_HEIGHT = "text-height"
	GLYPHICON_TEXT_WIDTH = "text-width"
	GLYPHICON_ALIGN_LEFT = "align-left"
	GLYPHICON_ALIGN_CENTER = "align-center"
	GLYPHICON_ALIGN_RIGHT = "align-right"
	GLYPHICON_ALIGN_JUSTIFY = "align-justify"
	GLYPHICON_LIST = "list"
	GLYPHICON_INDENT_LEFT = "indent-left"
	GLYPHICON_INDENT_RIGHT = "indent-right"
	GLYPHICON_FACETIME_VIDEO = "facetime-video"
	GLYPHICON_PICTURE = "picture"
	GLYPHICON_MAP_MARKER = "map-marker"
	GLYPHICON_ADJUST = "adjust"
	GLYPHICON_TINT = "tint"
	GLYPHICON_EDIT = "edit"
	GLYPHICON_SHARE = "share"
	GLYPHICON_CHECK = "check"
	GLYPHICON_MOVE = "move"
	GLYPHICON_STEP_BACKWARD = "step-backward"
	GLYPHICON_FAST_BACKWARD = "fast-backward"
	GLYPHICON_BACKWARD = "backward"
	GLYPHICON_PLAY = "play"
	GLYPHICON_PAUSE = "pause"
	GLYPHICON_STOP = "stop"
	GLYPHICON_FORWARD = "forward"
	GLYPHICON_FAST_FORWARD = "fast-forward"
	GLYPHICON_STEP_FORWARD = "step-forward"
	GLYPHICON_EJECT = "eject"
	GLYPHICON_CHEVRON_LEFT = "chevron-left"
	GLYPHICON_CHEVRON_RIGHT = "chevron-right"
	GLYPHICON_PLUS_SIGN = "plus-sign"
	GLYPHICON_MINUS_SIGN = "minus-sign"
	GLYPHICON_REMOVE_SIGN = "remove-sign"
	GLYPHICON_OK_SIGN = "ok-sign"
	GLYPHICON_QUESTION_SIGN = "question-sign"
	GLYPHICON_INFO_SIGN = "info-sign"
	GLYPHICON_SCREENSHOT = "screenshot"
	GLYPHICON_REMOVE_CIRCLE = "remove-circle"
	GLYPHICON_OK_CIRCLE = "ok-circle"
	GLYPHICON_BAN_CIRCLE = "ban-circle"
	GLYPHICON_ARROW_LEFT = "arrow-left"
	GLYPHICON_ARROW_RIGHT = "arrow-right"
	GLYPHICON_ARROW_UP = "arrow-up"
	GLYPHICON_ARROW_DOWN = "arrow-down"
	GLYPHICON_SHARE_ALT = "share-alt"
	GLYPHICON_RESIZE_FULL = "resize-full"
	GLYPHICON_RESIZE_SMALL = "resize-small"
	GLYPHICON_EXCLAMATION_SIGN = "exclamation-sign"
	GLYPHICON_GIFT = "gift"
	GLYPHICON_LEAF = "leaf"
	GLYPHICON_FIRE = "fire"
	GLYPHICON_EYE_OPEN = "eye-open"
	GLYPHICON_EYE_CLOSE = "eye-close"
	GLYPHICON_WARNING_SIGN = "warning-sign"
	GLYPHICON_PLANE = "plane"
	GLYPHICON_CALENDAR = "calendar"
	GLYPHICON_RANDOM = "random"
	GLYPHICON_COMMENT = "comment"
	GLYPHICON_MAGNET = "magnet"
	GLYPHICON_CHEVRON_UP = "chevron-up"
	GLYPHICON_CHEVRON_DOWN = "chevron-down"
	GLYPHICON_RETWEET = "retweet"
	GLYPHICON_SHOPPING_CART = "shopping-cart"
	GLYPHICON_FOLDER_CLOSE = "folder-close"
	GLYPHICON_FOLDER_OPEN = "folder-open"
	GLYPHICON_RESIZE_VERTICAL = "resize-vertical"
	GLYPHICON_RESIZE_HORIZONTAL = "resize-horizontal"
	GLYPHICON_HDD = "hdd"
	GLYPHICON_BULLHORN = "bullhorn"
	GLYPHICON_BELL = "bell"
	GLYPHICON_CERTIFICATE = "certificate"
	GLYPHICON_THUMBS_UP = "thumbs-up"
	GLYPHICON_THUMBS_DOWN = "thumbs-down"
	GLYPHICON_HAND_RIGHT = "hand-right"
	GLYPHICON_HAND_LEFT = "hand-left"
	GLYPHICON_HAND_UP = "hand-up"
	GLYPHICON_HAND_DOWN = "hand-down"
	GLYPHICON_CIRCLE_ARROW_RIGHT = "circle-arrow-right"
	GLYPHICON_CIRCLE_ARROW_LEFT = "circle-arrow-left"
	GLYPHICON_CIRCLE_ARROW_UP = "circle-arrow-up"
	GLYPHICON_CIRCLE_ARROW_DOWN = "circle-arrow-down"
	GLYPHICON_GLOBE = "globe"
	GLYPHICON_WRENCH = "wrench"
	GLYPHICON_TASKS = "tasks"
	GLYPHICON_FILTER = "filter"
	GLYPHICON_BRIEFCASE = "briefcase"
	GLYPHICON_FULLSCREEN = "fullscreen"
	GLYPHICON_DASHBOARD = "dashboard"
	GLYPHICON_PAPERCLIP = "paperclip"
	GLYPHICON_HEART_EMPTY = "heart-empty"
	GLYPHICON_LINK = "link"
	GLYPHICON_PHONE = "phone"
	GLYPHICON_PUSHPIN = "pushpin"
	GLYPHICON_USD = "usd"
	GLYPHICON_GBP = "gbp"
	GLYPHICON_SORT = "sort"
	GLYPHICON_SORT_BY_ALPHABET = "sort-by-alphabet"
	GLYPHICON_SORT_BY_ALPHABET_ALT = "sort-by-alphabet-alt"
	GLYPHICON_SORT_BY_ORDER = "sort-by-order"
	GLYPHICON_SORT_BY_ORDER_LT = "sort-by-order-alt"
	GLYPHICON_SORT_BY_ATTRIBUTES = "sort-by-attributes"
	GLYPHICON_SORT_BY_ATTRIBUTES_LT = "sort-by-attributes-alt"
	GLYPHICON_UNCHECKED = "unchecked"
	GLYPHICON_EXPAND = "expand"
	GLYPHICON_COLLAPSE_DOWN = "collapse-down"
	GLYPHICON_COLLAPSE_UP = "collapse-up"
	GLYPHICON_LOG_IN = "log-in"
	GLYPHICON_FLASH = "flash"
	GLYPHICON_LOG_OUT = "log-out"
	GLYPHICON_NEW_WINDOW = "new-window"
	GLYPHICON_RECORD = "record"
	GLYPHICON_SAVE = "save"
	GLYPHICON_OPEN = "open"
	GLYPHICON_SAVED = "saved"
	GLYPHICON_IMPORT = "import"
	GLYPHICON_EXPORT = "export"
	GLYPHICON_SEND = "send"
	GLYPHICON_FLOPPY_DISK = "floppy-disk"
	GLYPHICON_FLOPPY_SAVED = "floppy-saved"
	GLYPHICON_FLOPPY_REMOVE = "floppy-remove"
	GLYPHICON_FLOPPY_SAVE = "floppy-save"
	GLYPHICON_FLOPPY_OPEN = "floppy-open"
	GLYPHICON_CREDIT_CARD = "credit-card"
	GLYPHICON_TRANSFER = "transfer"
	GLYPHICON_CUTLERY = "cutlery"
	GLYPHICON_HEADER = "header"
	GLYPHICON_COMPRESSED = "compressed"
	GLYPHICON_EARPHONE = "earphone"
	GLYPHICON_PHONE_ALT = "phone-alt"
	GLYPHICON_TOWER = "tower"
	GLYPHICON_STATS = "stats"
	GLYPHICON_SD_VIDEO = "sd-video"
	GLYPHICON_HD_VIDEO = "hd-video"
	GLYPHICON_SUBTITLES = "subtitles"
	GLYPHICON_SOUND_STEREO = "sound-stereo"
	GLYPHICON_SOUND_DOLBY = "sound-dolby"
	GLYPHICON_SOUND_5_1 = "sound-5-1"
	GLYPHICON_SOUND_6_1 = "sound-6-1"
	GLYPHICON_SOUND_7_1 = "sound-7-1"
	GLYPHICON_COPYRIGHT_MARK = "copyright-mark"
	GLYPHICON_REGISTRATION_MARK = "registration-mark"
	GLYPHICON_CLOUD_DOWNLOAD = "cloud-download"
	GLYPHICON_CLOUD_UPLOAD = "cloud-upload"
	GLYPHICON_TREE_CONIFER = "tree-conifer"
	GLYPHICON_TREE_DECIDUOUS = "tree-deciduous"

	def __init__(self, parent, icon_name, icon_clazz="glyphicon"):
		super(MikanBootstrapIconViewlet, self).__init__(parent)
#		self.clazz = "glyphicon glyphicon-%s" % icon_name
		self.sortkey = 1
		self.FIconName = icon_name
		self.FIconClazz = icon_clazz

	def perform(self):
		self.clazz = "%s %s-%s" % (self.iconclazz, self.iconclazz, self.iconname)

		return super(MikanBootstrapIconViewlet, self).perform()

	def set_icon_name(self, value):
		self.FIconName = value

	def get_icon_name(self):
		return self.FIconName

	def set_icon_clazz(self, value):
		self.FIconClazz = value

	def get_icon_clazz(self):
		return self.FIconClazz

	# ----------------------------------------------------
	## Property
	iconclazz = ESiPCProperty(get_icon_clazz, set_icon_clazz, None)
	iconname = ESiPCProperty(get_icon_name, set_icon_name, None)

class MikanBootstrapTooltipViewlet(MikanBootstrapIconViewlet):

	def __init__(self, parent, tooltip):
		super(MikanBootstrapTooltipViewlet, self).__init__(parent, "question-sign")
		self.sortkey = -1

		self.set_attribute_value("data-toggle", "tooltip")
		self.set_attribute_value("data-placement", "top")
		self.set_attribute_value("title", tooltip)

class MikanBootstrapLabelViewlet(AbstractMikanBootstrapSpanViewlet):

	LABEL_DEFAULT = MIKAN_BOOTSTRAP.DEFAULT
	LABEL_PRIMARY = MIKAN_BOOTSTRAP.PRIMARY
	LABEL_SUCCESS = MIKAN_BOOTSTRAP.SUCCESS
	LABEL_INFO = MIKAN_BOOTSTRAP.INFO
	LABEL_WARNING = MIKAN_BOOTSTRAP.WARNING
	LABEL_DANGER = MIKAN_BOOTSTRAP.DANGER

	def __init__(self, parent, label_name):
		super(MikanBootstrapLabelViewlet, self).__init__(parent)
		self.clazz = "label  label-%s" % label_name

class MikanBootstrapBadgeViewlet(AbstractMikanBootstrapSpanViewlet):

	LABEL_DEFAULT = MIKAN_BOOTSTRAP.DEFAULT
	LABEL_PRIMARY = MIKAN_BOOTSTRAP.PRIMARY
	LABEL_SUCCESS = MIKAN_BOOTSTRAP.SUCCESS
	LABEL_INFO = MIKAN_BOOTSTRAP.INFO
	LABEL_WARNING = MIKAN_BOOTSTRAP.WARNING
	LABEL_DANGER = MIKAN_BOOTSTRAP.DANGER

	def __init__(self, parent, nodevalue, right=False, left=False):
		super(MikanBootstrapLabelViewlet, self).__init__(parent, nodevalue=nodevalue)
		self.clazz = "badge"

		if self.left:
			self.clazz = "%s %s" % (self.clazz, MIKAN_BOOTSTRAP.PULL_LEFT)
		elif self.right:
			self.clazz = "%s %s" % (self.clazz, MIKAN_BOOTSTRAP.PULL_RIGHT)

class MikanBootstrapAlertViewlet(AbstractMikanBootstrapDivViewlet):

	ALERT_PRIMARY = MIKAN_BOOTSTRAP.PRIMARY
	ALERT_SUCCESS = MIKAN_BOOTSTRAP.SUCCESS
	ALERT_INFO = MIKAN_BOOTSTRAP.INFO
	ALERT_WARNING = MIKAN_BOOTSTRAP.WARNING
	ALERT_DANGER = MIKAN_BOOTSTRAP.DANGER

	def set_dismissable(self, value):
		self.FDismissable = value

	def is_dismissable(self):
		return self.FDismissable

	def __init__(self, parent, nodevalue, alert_type=ALERT_PRIMARY, dismissable=False, icon_name=MikanBootstrapIconViewlet.GLYPHICON_EXCLAMATION_SIGN):
		super(MikanBootstrapAlertViewlet, self).__init__(parent)
		self.nodevalue = nodevalue
		self.clazz = "alert alert-%s" % alert_type

		self.FDismissable = dismissable

		if icon_name:
			MikanBootstrapIconViewlet(self, icon_name)

	def perform(self):
		if self.isdismissable:
			button = MikanButtonViewlet(self)
			button.clazz = "close"
			MikanCDataViewlet(button, "&times;")
			button.type = "button"
			button.set_attribute_value("data-dismiss", "alert")
			button.set_attribute_value("aria-hidden", "true")

		return super(MikanBootstrapAlertViewlet, self).perform()

	# ----------------------------------------------------
	## Property
	isdismissable = ESiPCProperty(is_dismissable, set_dismissable, None)

class MikanBootstrapCaretViewlet(AbstractMikanBootstrapSpanViewlet):

	def __init__(self, parent):
		super(MikanBootstrapCaretViewlet, self).__init__(parent)
		self.clazz = MIKAN_BOOTSTRAP.CARET

class MikanBootstrapButtonViewlet(MikanButtonViewlet, AbstractMikanBootstrapButtonViewlet):

	def __init__(self, parent, button_type=AbstractMikanBootstrapButtonViewlet.BUTTON_DEFAULT, size=None, active=False, block=False, disabled=False, tooltip=None):
		super(MikanBootstrapButtonViewlet, self).__init__(parent)

		self.setup_clazz(button_type, size, active, block, tooltip=tooltip)
		self.type = "button"

		if disabled:
			self.disabled = "disabled"

class MikanBootstrapButtonInputViewlet(MikanInputViewlet, AbstractMikanBootstrapButtonViewlet):

	def __init__(self, parent, button_type=AbstractMikanBootstrapButtonViewlet.BUTTON_DEFAULT, size=None, active=False, block=False, disabled=False, tooltip=None):
		super(MikanBootstrapButtonInputViewlet, self).__init__(parent, name="")

		self.setup_clazz(button_type, size, active, block, tooltip=tooltip)
		self.type = "button"

		if disabled:
			self.disabled = "disabled"

class MikanBootstrapButtonAViewlet(MikanAViewlet, AbstractMikanBootstrapButtonViewlet):

	def __init__(self, parent, button_type=AbstractMikanBootstrapButtonViewlet.BUTTON_DEFAULT, size=None, active=False, block=False, disabled=False, tooltip=None):
		super(MikanBootstrapButtonAViewlet, self).__init__(parent)

		self.setup_clazz(button_type, size, active, block, tooltip=tooltip)
		self.role = "button"

		if disabled:
			self.clazz = "%s %s" % (self.clazz, "disabled")

class MikanBootstrapBreadcrumbsViewlet(MikanOlViewlet, MIKAN_BOOTSTRAP):

	def get_items(self):
		return self.FItems

	def __init__(self, parent, items=[]):
		super(MikanBootstrapBreadcrumbsViewlet, self).__init__(parent)

		self.clazz = "breadcrumb"
		self.FItems = items

	def perform(self):
		add_link_items(self, self.items)

		return super(MikanMenusViewlet, self).perform()

	# ----------------------------------------------------
	## Property
	items = ESiPCProperty(get_items, None, None)

class MikanBootstrapPaginationViewlet(MikanUlViewlet, MIKAN_BOOTSTRAP):

	def get_items(self):
		return self.FItems

	def __init__(self, parent, items=[]):
		super(MikanBootstrapPaginationViewlet, self).__init__(parent)

		self.clazz = "pagination"
		self.FItems = items

	def perform(self):
		add_link_items(self, self.items)

		return super(MikanMenusViewlet, self).perform()

	# ----------------------------------------------------
	## Property
	items = ESiPCProperty(get_items, None, None)

class MikanBootstrapPagerViewlet(MikanBootstrapPaginationViewlet, MIKAN_BOOTSTRAP):

	def __init__(self, parent, items=[]):
		super(MikanBootstrapPagerViewlet, self).__init__(parent, items)

		self.clazz = "pager"

class MikanBootstrapInlineViewlet(MikanDlViewlet, MIKAN_BOOTSTRAP):

	def __init__(self, parent):
		super(MikanBootstrapInlineViewlet, self).__init__(parent)
		self.clazz = "dl-horizontal"

	def add_item(self, label, text):
		l = MikanDtViewlet(self, label)
		t = MikanDdViewlet(self, text)
		return (l, t)

class MikanBootstrapListGroupViewlet(MikanUlViewlet, MIKAN_BOOTSTRAP):

	def __init__(self, parent):
		super(MikanBootstrapListGroupViewlet, self).__init__(parent)
		self.clazz = "list-group"

	def add_item(self, text=None):
		d = MikanLiViewlet(self, text)
		d.clazz = "list-group-item"
		return d

	def set_title(self, text=None):
		d = self.add_item(text)
		d.sortkey = 0
		d.clazz = d.clazz + " active"
		return d

class MikanBootstrapNavBarViewlet(AbstractMikanBootstrapDivViewlet):

	def get_container(self):
		return self.FContainer

	def __init__(self, parent, container):
		super(MikanBootstrapNavBarViewlet, self).__init__(parent)
		self.clazz = "navbar navbar-inverse"
		self.role = "navigation"

		if container:
			self.FContainer = MikanDivViewlet(self)
			self.container.clazz = "container"
			self.role = "contentinfo"
		else:
			self.FContainer = self

	# ----------------------------------------------------
	## Property
	container = ESiPCProperty(get_container, None, None)

class MikanBootstrapNavItem(object):

	def __init__(self, title, icon=None, href=None, target=None, onclick=None, active=False, disabled=False, items=None):
		super(MikanBootstrapNavItem, self).__init__()

		self.icon = icon
		self.title = title
		self.href = href
		self.target = target
		self.onclick = onclick
		self.active = active
		self.disabled = disabled
		self.items = items
		if items == None:
			self.items = []

	def add_item(self, title, icon=None, href=None, target=None, onclick=None, active=False, disabled=False,items=None):
		self.items.append(MikanBootstrapNavItem(title, icon=icon, href=href, target=target, onclick=onclick, active=active, disabled=disabled, items=items))

class MikanBootstrapNavTabsItem(MikanBootstrapNavItem):

	def __init__(self, id, title, icon=None, href=None, target=None, onclick=None, active=False, disabled=False,items=None):
		super(MikanBootstrapNavTabsItem, self).__init__(title, icon=icon, href=href, target=target, onclick=onclick, active=active, disabled=disabled, items=items)

		self.id = id

class MikanBootstrapNavViewlet(AbstractMikanBootstrapUlViewlet):

	def get_items(self):
		return self.FItems

	def __init__(self, parent, pills=False, stacked=False, justified=False, items=None):
		super(MikanBootstrapNavViewlet, self).__init__(parent)
		self.clazz = "nav"
		if pills:
			self.clazz = self.clazz + " nav-pills"
		else:
			self.clazz = self.clazz + " nav-tabs"
		if stacked:
			self.clazz = self.clazz + " nav-stacked"
		if justified:
			self.clazz = self.clazz + " nav-justified"

		if items == None:
			self.FItems = []

	def add_item(self, title, href=None, target=None, onclick=None, active=False, disabled=False,items=None):
		item = MikanBootstrapNavItem(title, href, target, onclick, active, disabled,items)
		self.items.append(item)

		return item

	def build_content(self):
		for item in self.items:
			li = MikanLiViewlet(self)
			if item.active:
				li.clazz = "active"
			elif item.disabled:
				li.clazz = "disabled"
			href = item.href
			if href == None:
				href = "#"
			a = MikanAViewlet(li, href=href)
			if item.icon:
				MikanBootstrapIconViewlet(a, item.icon).sortkey = 0
			MikanTextViewlet(a, item.title)

	# ----------------------------------------------------
	## 処理
	# @return Trueなら続行
	def perform(self):
		# コンテンツ構築
		self.build_content()

		# 継承元実行
		return super(MikanBootstrapNavViewlet, self).perform()

	# ----------------------------------------------------
	## Property
	items = ESiPCProperty(get_items, None, None)

class MikanBootstrapNavTabsViewlet(MikanBootstrapNavViewlet):

	def __init__(self, parent, justified=False, items=None):
		super(MikanBootstrapNavTabsViewlet, self).__init__(parent, pills=False, justified=justified, items=items)

	def add_tab(self, id, title, icon=None, active=False, disabled=False,items=None):
		item = MikanBootstrapNavTabsItem(id, title, icon=icon, href="#%s" % id, active=active, disabled=disabled, items=items)
		self.items.append(item)

		return item

	def build_content(self):
		super(MikanBootstrapNavTabsViewlet, self).build_content()

		nav_panel = MikanBootstrapPanelViewlet(self.parent, u"")
		nav_panel.header.isvisible = False

		content = MikanDivViewlet(nav_panel.body)
		content.clazz = "tab-content"

		for item in self.items:
			div = MikanDivViewlet(content)
			div.id = item.id
			div.clazz = "tab-pane"
			if item.active:
				div.clazz = div.clazz + " active"
			elif item.disabled:
				div.clazz = div.clazz + " disabled"

			for i in item.items:
				button = MikanBootstrapButtonAViewlet(div, disabled=item.disabled)
				if i.icon:
					MikanBootstrapIconViewlet(button, i.icon).sortkey = 0
				MikanTextViewlet(button, i.title)
				if i.onclick:
					button.onclick = i.onclick
				if i.href:
					button.href = i.href

	# ----------------------------------------------------
	## Property

class MikanBootstrapNavPillsViewlet(MikanBootstrapNavViewlet):

	def __init__(self, parent, stacked=False, justified=False, items=None):
		super(MikanBootstrapNavPillsViewlet, self).__init__(parent, pills=True, stacked=stacked, justified=justified, items=items)

	# ----------------------------------------------------
	## Property

class MikanBootstrapCarouselSlideViewlet(MikanDivViewlet, MIKAN_BOOTSTRAP):

	def set_url(self, value):
		self.FURL = value

	def get_url(self):
		return self.FURL

	def set_count(self, value):
		self.FCount = value

	def get_count(self):
		return self.FCount

	def get_items(self):
		return self.FItems

	# ----------------------------------------------------
	## コンストラクタ
	#  @param parent 親Viewlet
	#  @param value ノード値
	def __init__(self, parent, count=10):
		super(MikanBootstrapCarouselSlideViewlet, self).__init__(parent)
		self.FURL = None
		self.FItems = {}
		self.FCount = count
		self.clazz ="carousel slide"
		self.id = "carousel-logo-generic"

	def add_image(self, id, message=None, image=None, url=None):
		self.add_image_item(MikanBannerSilderItem(id, message, image, url))

	def add_image_item(self, item):
		self.items[item.id] = item

	def get_image_item(self, id):
		return self.items[id]

	def remove_image_item(self, id):
		del(self.item[id])

	def build_content(self):
		ol = MikanOlViewlet(self)
		ol.clazz = "carousel-indicators"
		div = MikanDivViewlet(self)
		div.clazz = "carousel-inner"

		image_url = self.url
		if image_url == None:
			image_url = self.request.imageurl + "/%s"

		items = self.items.values()
		Random().shuffle(items)
		first = True
		count = 0
		for item in items:
#			print "%d / %d" % (count, self.count)
			if (self.count != 0) and (count >= self.count):
				break

			id = item.id
			image = item.image
			if image == None:
				image = id
			url = item.url

			li = MikanLiViewlet(ol)
			li.set_attribute_value("data-target", "#%s" % self.id)
			li.set_attribute_value("data-slide-to", count)

			d = MikanDivViewlet(div)
			d.clazz = "item"
			img = MikanImgViewlet(d, alt="", src=image_url % image)
#			img.set_attribute_value("data-src", image_url % image)

			c = MikanDivViewlet(d)
			c.clazz = "carousel-caption"

			if first:
#				img.src = image_url % image
				d.clazz = d.clazz + " active"
				li.clazz = "active"
				first = False
			count = count + 1

	# ----------------------------------------------------
	## 処理
	# @return Trueなら続行
	def perform(self):

		# コンテンツ構築
		self.build_content()

		# 継承元実行
		if not super(MikanBootstrapCarouselSlideViewlet, self).perform():
			return False

		# 属性設定
		self.set_element_attribute("data-ride", "carousel")

		# 実行結果
		return True

	# ----------------------------------------------------
	## Property
	items = ESiPCProperty(get_items, None, None)
	url = ESiPCProperty(get_url, set_url, None)
	count = ESiPCProperty(get_count, set_count, None)

class MikanBootstrapMediaViewlet(AbstractMikanBootstrapDivViewlet):

	def get_media_image(self):
		return self.FMediaImage

	def get_media_body(self):
		return self.FMediaBody

	def __init__(self, parent, href=None, src=None, alt=None, right=False, title=None):
		super(MikanBootstrapMediaViewlet, self).__init__(parent)
		self.clazz = "media"

		self.FMediaImage = None
		if href != None:
			self.FMediaImage = MikanAViewlet(self, href=href)
			if right:
				self.FMediaImage.clazz = "pull-right"
			else:
				self.FMediaImage.clazz = "pull-left"
			img = MikanImgViewlet(self.FMediaImage, src=src, alt=alt)
			img.clazz = "icon_large media-object"

		self.FMediaBody = MikanDivViewlet(self)
		if title != None:
			MikanH4Viewlet(self.mediabody, title)

	def perform(self):
		return super(MikanBootstrapMediaViewlet, self).perform()

	# ----------------------------------------------------
	## Property
	mediaimage = ESiPCProperty(get_media_image, None, None)
	mediabody = ESiPCProperty(get_media_body, None, None)

class MikanBootstrapJumbotronViewlet(AbstractMikanBootstrapDivViewlet):

	def __init__(self, parent):
		super(MikanBootstrapJumbotronViewlet, self).__init__(parent)
		self.clazz = "jumbotron"

class MikanBootstrapPageHeaderViewlet(AbstractMikanBootstrapDivViewlet):

	def __init__(self, parent):
		super(MikanBootstrapPageHeaderViewlet, self).__init__(parent)
		self.clazz = "page-header"

class MikanBootstrapCodeViewlet(MikanPreViewlet, MIKAN_BOOTSTRAP):

	def set_code(self, value):
		self.FCode = value

	def get_code(self):
		return self.FCode

	def __init__(self, parent, code):
		super(MikanBootstrapCodeViewlet, self).__init__(parent)
		self.FCode = code

	def perform(self):
		code = MikanCodeViewlet(self, self.code)

		return super(MikanBootstrapMediaViewlet, self).perform()

	# ----------------------------------------------------
	## Property
	code = ESiPCProperty(get_code, set_code, None)

class MikanBootstrapModalViewlet(AbstractMikanBootstrapDivViewlet):

	def __init__(self, parent):
		super(MikanBootstrapModalViewlet, self).__init__(parent)
		self.clazz = "modal fade"
		self.role = "dialog"

class MikanBootstrapContentModalViewlet(MikanBootstrapModalViewlet):

	def get_title(self):
		return self.FTitle

	def set_title(self, value):
		self.FTitle = value

	def is_close(self):
		return self.FClose

	def set_close(self, value):
		self.FClose = value

	def get_content(self):
		return self.FContent

	def get_header(self):
		return self.FHeader

	def get_body(self):
		return self.FBody

	def get_footer(self):
		return self.FFooter

	def __init__(self, parent, title, close=True):
		super(MikanBootstrapContentModalViewlet, self).__init__(parent)

		self.FTitle = title
		self.FClose = close

		dialog = MikanDivViewlet(self)
		dialog.clazz = "modal-dialog"

		self.FContent = MikanDivViewlet(dialog)
		self.content.clazz = "modal-content"

		self.FHeader = MikanDivViewlet(self.content)
		self.header.clazz = "modal-header"

		self.FBody = MikanDivViewlet(self.content)
		self.body.clazz = "modal-body"

		self.FFooter = MikanDivViewlet(self.content)
		self.footer.clazz = "modal-footer"

	def perform(self):
		if self.close:
			button = MikanButtonViewlet(self.header)
			button.clazz = "close"
			MikanCDataViewlet(button, "&times;")
			button.type = "button"
			button.set_attribute_value("data-dismiss", "modal")
			button.set_attribute_value("aria-hidden", "true")

			button = MikanBootstrapButtonViewlet(self.footer)
			button.nodevalue = u"閉じる"
			button.set_attribute_value("data-dismiss", "modal")



		title = MikanH4Viewlet(self.header, self.title)
		title.clazz = "modal-title"

		MikanBootstrapIconViewlet(title, "comment")

		return super(MikanBootstrapContentModalViewlet, self).perform()

	# ----------------------------------------------------
	## Property
	title = ESiPCProperty(get_title, set_title, None)
	close = ESiPCProperty(is_close, set_close, None)
	content = ESiPCProperty(get_content, None, None)
	header = ESiPCProperty(get_header, None, None)
	body = ESiPCProperty(get_body, None, None)
	footer = ESiPCProperty(get_footer, None, None)

class MikanBootstrapContentFormModalViewlet(MikanBootstrapContentModalViewlet):

	def get_form(self):
		return self.FForm

	def __init__(self, parent, title, close=True, action=None, target=None, method="POST", name=None, enctype="multipart/form-data"):
		super(MikanBootstrapContentFormModalViewlet, self).__init__(parent, title, close)

		self.FForm = MikanBootstrapFormViewlet(self.body, action, target, method, name, enctype)

	def perform(self):
		button = MikanBootstrapButtonViewlet(self.footer)
		button.nodevalue = u"実行"
		button.onclick = "mikan.form.submit(document.%s);" % (self.form.name)
		button.set_attribute_value("data-dismiss", "modal")

		return super(MikanBootstrapContentFormModalViewlet, self).perform()

	# ----------------------------------------------------
	## Property
	form = ESiPCProperty(get_form, None, None)

class MikanBootstrapFormViewlet(MikanFormViewlet, MIKAN_BOOTSTRAP):

	def get_form_action(self):
		return self.FFormAction

	def __init__(self, parent, action=None, target=None, method="POST", name=None, enctype="multipart/form-data"):
		super(MikanBootstrapFormViewlet, self).__init__(parent, action, target, method, name, enctype)
		self.clazz = "form-horizontal"
		self.role = "form"

		if action != None:
			self.FFormAction = action
		else:
			try:
				s = self.request.pathinfo.split("/")
				self.FFormAction = s[len(s) - 1]
			except:
				self.FFormAction = self.request.scriptname + self.request.pathinfo

	def add_select(self, label, name, required=False, form=None):
		d = form
		if d == None:
			d = self.add_form_group()

		la = MikanLabelViewlet(d, label)
		la.clazz = "col-sm-3 control-label"
		la.f0r = name

		i = MikanDivViewlet(d)
		i.clazz = "col-sm-9"

		input = MikanSelectViewlet(i, name)
		input.placeholder = label
		input.id = name
		input.size = 1

		return (d, la, input)

	def add_form_group(self):
		d = MikanDivViewlet(self)
		d.clazz = "form-group"

		return d

	def add_email(self, label, name, value=None, required=False, form=None):
		d = form
		if d == None:
			d = self.add_form_group()

		la = MikanLabelViewlet(d, label)
		la.clazz = "col-sm-3 control-label"
		la.f0r = name

		i = MikanDivViewlet(d)
		i.clazz = "col-sm-9"

		input = MikanInputViewlet(i, name, "email", value)
		input.placeholder = label
		input.id = name
		input.size = 96
		input.length = 256

#		if required:
#			icon = MikanBootstrapIconViewlet(i, "hand-right")
#			icon.clazz = icon.clazz + " input-group-addon"
#			icon.sortkey = -9999

		return (d, la, input)

	def add_checkbox(self, label, name, value=u"True", checked="True", required=False, form=None):
		d = form
		if d == None:
			d = self.add_form_group()

		c = MikanDivViewlet(d)
		c.clazz = "col-sm-offset-3 col-sm-9"

		b = MikanDivViewlet(self)
		b.clazz = "checkbox"

		l = MikanLabelViewlet(b)

		input = MikanCheckboxInputViewlet(l, name, value)
		input.clazz = "checkbox"
		if checked:
			input.checked = "true"

		l.nodevalue = label

		return (d, l, input)

	def add_button(self, parent, title, url=None, click=None, tooltip=None):
		b = MikanBootstrapButtonAViewlet(parent, tooltip=tooltip)
		b.href = url
		b.onclick = click
		b.nodevalue = title

		return b

	# ----------------------------------------------------
	## Property
	formaction = property(get_form_action, None, None)

class AbstractMikanBaseFormViewlet(MikanBootstrapFormViewlet):

	def is_top_buttons(self):
		return self.FTopButtons

	def set_top_buttons(self, value):
		self.FTopButtons = value

	def is_bottom_buttons(self):
		return self.FBottomButtons

	def set_bottom_buttons(self, value):
		self.FBottomButtons = value

	def __init__(self, parent, action=None, target=None, method="POST", name=None, enctype="multipart/form-data"):
		super(AbstractMikanBaseFormViewlet, self).__init__(parent, action, target, method, name, enctype)

		self.FTopButtons = True
		self.FBottomButtons = True

	def build_buttons(self, parent):
		self.add_buttons(parent)

		MikanHrViewlet(parent)

		return parent

	def add_buttons(self, parent):
		return parent

	def add_content(self, table):
		# フォーム本体
		return MikanTbodyViewlet(table)

	def build_content(self):
		# エラー表示
		MikanBootstrapExceptionsViewlet(self)

		# フォーム
		self.name="item"

		# ボタン
		if self.istopbuttons:
			self.build_buttons(self)

		# テーブル
		table = MikanTableViewlet(self)
		table.clazz = "table table-hover table-bordered table-striped"
		table.id = "item_list"

		# フォーム本体
		self.add_content(table)

		# ボタン
		if self.isbottombuttons:
			self.build_buttons(self)

	# ----------------------------------------------------
	## 処理
	# @return Trueなら続行
	def perform(self):
		self.action = self.formaction

		# コンテンツ構築
		self.build_content()

		# 継承元実行
		if not super(AbstractMikanBaseFormViewlet, self).perform():
			return False

		# 実行結果
		return True

	# ----------------------------------------------------
	## Property
	istopbuttons = property(is_top_buttons, set_top_buttons, None)
	isbottombuttons = property(is_bottom_buttons, set_bottom_buttons, None)

class MikanBootstrapBaseFormViewlet(AbstractMikanBaseFormViewlet):

	def __init__(self, parent, action=None, name=None, method="post", target=None):
		super(MikanBootstrapBaseFormViewlet, self).__init__(parent, action, name, method, target)
		self.FOnContent = None

	def get_submit_caption(self):
		return u"実行"

	def is_reset(self):
		return False

	def get_reset_caption(self):
		return u"初期値"

	def get_submit_code(self):
		return "mikan.form.submit();"

	def get_reset_code(self):
		return "mikan.form.reset();"

	def get_back_caption(self):
		return u"戻る"

	def get_back_code(self):
		return "mikan.page.back();"

	def get_clear_caption(self):
		return u"クリア"

	def get_clear_code(self):
		return "mikan.form.clear();"

	def add_buttons(self, parent):
		buttons = super(MikanBootstrapBaseFormViewlet, self).add_buttons(parent)

		self.add_button(buttons, self.submitcaption, None, self.submitcode)
		if self.isreset:
			self.add_button(buttons, self.resetcaption, None, self.resetcode)

		return buttons

	def add_content(self, table):
		tbody = super(MikanBootstrapBaseFormViewlet, self).add_content(table)

		if self.oncontent != None:
			self.oncontent(table, tbody)

	def set_oncontent(self, value):
		self.FOnContent = value

	def get_oncontent(self):
		return self.FOnContent

	# ----------------------------------------------------
	## Property
	oncontent = ESiPCProperty(get_oncontent, set_oncontent, None)
	submitcaption = ESiPCProperty(get_submit_caption, None, None)
	isreset = ESiPCProperty(is_reset, None, None)
	resetcaption = ESiPCProperty(get_reset_caption, None, None)
	clearcaption = ESiPCProperty(get_clear_caption, None, None)
	backcaption = ESiPCProperty(get_back_caption, None, None)
	submitcode = ESiPCProperty(get_submit_code, None, None)
	resetcode = ESiPCProperty(get_reset_code, None, None)
	clearcode = ESiPCProperty(get_clear_code, None, None)
	backcode = ESiPCProperty(get_back_code, None, None)

class MikanBootstrapExceptionsViewlet(AbstractMikanBootstrapDivViewlet):
	def __init__(self, parent):
		super(MikanBootstrapExceptionsViewlet, self).__init__(parent)

	def prepare(self):
		return len(self.request.exceptions) > 0

	def perform(self):
		for e in self.request.exceptions:
			if self.islogdebug:
				self.logger.debug(e)

			msg = ""
			try:
				msg = e.__str__()
			except:
				msg = e
			try:
				msg = msg.decode(sys.getdefaultencoding())
			except:
				try:
					msg = msg.decode("shift_jis")
				except:
					msg = msg

			MikanBootstrapAlertViewlet(self, msg, alert_type=MikanBootstrapAlertViewlet.ALERT_DANGER, dismissable=True)

		return super(MikanBootstrapExceptionsViewlet, self).perform()

class MikanBootstrapPanelViewlet(AbstractMikanBootstrapDivViewlet):

	PANEL_DEFAULT = MIKAN_BOOTSTRAP.DEFAULT
	PANEL_PRIMARY = MIKAN_BOOTSTRAP.PRIMARY
	PANEL_SUCCESS = MIKAN_BOOTSTRAP.SUCCESS
	PANEL_INFO = MIKAN_BOOTSTRAP.INFO
	PANEL_WARNING = MIKAN_BOOTSTRAP.WARNING
	PANEL_DANGER = MIKAN_BOOTSTRAP.DANGER

	def get_icon_name(self):
		return self.FIconName

	def set_icon_name(self, value):
		self.FIconName = value

	def get_title(self):
		return self.FTitle

	def set_title(self, value):
		self.FTitle = value

	def get_header(self):
		return self.FHeader

	def get_body(self):
		return self.FBody

	def get_footer(self):
		return self.FFooter

	def __init__(self, parent, title, panel_type=PANEL_DEFAULT, icon_name=None):
		super(MikanBootstrapPanelViewlet, self).__init__(parent)
		self.clazz = "panel panel-%s" % panel_type

		self.FTitle = title
		self.FIconName = icon_name

		self.FHeader = MikanDivViewlet(self)
		self.header.clazz = "panel-heading"

		self.FBody = MikanDivViewlet(self)
		self.body.clazz = "panel-body"

		self.FFooter = MikanDivViewlet(self)
		self.footer.clazz = "panel-footer"
		self.footer.isvisibled = False

	def perform(self):
		title = MikanH4Viewlet(self.header)
		title.clazz = "panel-title"
		if self.iconname:
			MikanBootstrapIconViewlet(title, self.iconname)
			title.nodevalue = u" " + self.title
		else:
			title.nodevalue = self.title

		if len(self.footer.performs) == 0:
			self.footer.isvisible = False

		return super(MikanBootstrapPanelViewlet, self).perform()

	# ----------------------------------------------------
	## Property
	title = ESiPCProperty(get_title, set_title, None)
	iconname = ESiPCProperty(get_icon_name, set_icon_name, None)
	header = ESiPCProperty(get_header, None, None)
	body = ESiPCProperty(get_body, None, None)
	footer = ESiPCProperty(get_footer, None, None)

class MikanBootstrapProgressViewlet(AbstractMikanBootstrapDivViewlet):

	def __init__(self, parent, valuenow=100):
		super(MikanBootstrapProgressViewlet, self).__init__(parent)
		self.clazz = "progress"

		div = MikanDivViewlet(self)
		div.clazz = "progress-bar progress-bar-success progress-bar-striped active"
		div.role = "progressbar"
		div.set_attribute_value("aria-valuenow", valuenow)
		div.set_attribute_value("aria-valuemin", "0")
		div.set_attribute_value("aria-valuemax", "100")
		div.set_attribute_value("style", "width: " + str(valuenow) + "%")

# ------------------------------------------------------------
## Main Section
# ------------------------------------------------------------

# ------------------------------------------------------------
